package org.example.binaryoperator;

import java.util.function.IntBinaryOperator;
import java.util.stream.IntStream;

public class Java8BinaryOperator3 {
    public static void main(String[] args) {
        int[] numbers = IntStream.range(1,11).toArray();
        int result = math(numbers,0, Integer::sum);
        System.err.println(result);
    }

    static int math(int[] list, int init, IntBinaryOperator operator){
        int result = init;
        for (int i : list) {
            result = operator.applyAsInt(result,i);
        }
        return result;
    }
}
